#include<iostream>

using namespace std;
const int N = 110;
double p[N];
int cnt[N];
int main()
{
    int n; cin >> n;
    for (int i = 1; i <= n; i++) cin >> p[i];
    int x,y;
    double sum = 0.0;
    while (cin >> x >> y, x)
    {
        cnt[x]+= y;
        sum += p[x] * y;
    }
    for (int i = 1; i <= n; i++) cout << cnt[i] << endl;
    printf("%.2f", sum);
    return 0;
}